//
//  FXTreeNode.h
//  FetionDataStructure
//
//  Created by Ronnie on 08-12-2.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "FXUserInfo.h"
@class DialogWindowController;


@interface FXTreeNode : NSObject {
	// data in this node, if this is a leaf node
	FXUserInfo*		user_info;
	
	// is a group 
	bool			isLeaf;
	
	// if this node is a group, then all the children are here
	int				groupId;
	NSString*		groupName;
	NSMutableArray*	nodeChildren;
	FXTreeNode*		nodeParent;
	
	// for dialog 
	DialogWindowController*	dialogWindowCtrl;
	NSMutableArray*			chatHistory;
}

- (id)initLeafNodeWithUserInfo:(FXUserInfo*)user parent:(FXTreeNode*)parent;
- (id)initGroupNodeWithId:(int)gId name:(NSString*)gName parent:(FXTreeNode*)parent;

- (bool)isLeaf;
- (bool)isGroup;
- (bool)isExpandable;

- (int)groupId;
- (FXUserInfo*)getUserInfo;
- (NSString*)getGroupName;
- (void)updateGroupName;
- (DialogWindowController*)getDialogWindowContorller;
- (void)setDialogWindowController:(DialogWindowController*)ctrl;
- (void)releaseDialogWindowController;
- (NSMutableArray*)getChatHistory;
- (FXTreeNode*)getNodeParent;

- (void)setParent:(FXTreeNode*)parent;
- (void)insertChild:(FXTreeNode*)child atIndex:(int)index;
- (int)numberOfChildren;
- (FXTreeNode*)childAtIndex:(int)index;
- (void)removeChild:(FXTreeNode*)object;

- (void)getMessage:(NSString*)msg;
- (void)addAttributedString:(NSAttributedString*)string;
- (void)PrintTreeNode;

- (NSComparisonResult)compare:(FXTreeNode*)other;
- (void)recursiveSortChildren;
- (void)sortChildren;

@end
